package com.dz.risk.common.utils;

import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static org.apache.commons.lang3.StringUtils.isNotEmpty;

/**
 * 字符串工具类
 *
 * @author Doke
 * @date 2021/8/9 9:22
 */
public class ZyStringUtils extends StringUtils {

    private final static Pattern SPLIT_COMMA = Pattern.compile(",");

    /**
     * 逗号分隔的字符串拆分为list
     *
     * @param str 待拆分的字符串
     * @return
     */
    public static List<String> splitToList(String str) {
        List<String> collect = new ArrayList<>();
        if (isNotEmpty(str)) {
            collect.addAll(SPLIT_COMMA.splitAsStream(str).collect(Collectors.toList()));
        }
        return collect;
    }

}
